#pragma once

struct AABB
{
  glm::vec3 minPoint;
  glm::vec3 maxPoint;

  explicit constexpr AABB(const glm::vec3 &minPoint, const glm::vec3 &maxPoint)
      : minPoint(minPoint),
        maxPoint(maxPoint) {}

  static AABB FromBlockPosition(const glm::vec3 &position) { return AABB(position, position + glm::vec3{1, 1, 1}); }

  // 检测相交
  bool Intersect(const AABB &aabb) const
  {
    return (GetMinX() <= aabb.GetMaxX() && GetMaxX() >= aabb.GetMinX()) &&
           (GetMinY() <= aabb.GetMaxY() && GetMaxY() >= aabb.GetMinY()) &&
           (GetMinZ() <= aabb.GetMaxZ() && GetMaxZ() >= aabb.GetMinZ());
  }

  float GetMinX() const { return minPoint.x; };
  float GetMinY() const { return minPoint.y; };
  float GetMinZ() const { return minPoint.z; };
  float GetMaxX() const { return maxPoint.x; };
  float GetMaxY() const { return maxPoint.y; };
  float GetMaxZ() const { return maxPoint.z; };
};